<template>
  <el-container class="home-container">
    <!-- 头部区域 -->
    <el-header>
      <div @click="handleLogoLink">
        <img src="../assets/py-logo.png" alt="" />
        <span>业绩管理系统</span>
      </div>
      <!--  个人首页、项目、论文、竞赛 -->
      <el-menu
        :default-active="activePath"
        class="el-menu-demo"
        mode="horizontal"
        @select="handleSelect"
        background-color="#373d41"
        text-color="#fff"
        active-text-color="#ffd04b"
        router
        unique-opened
      >
        <el-menu-item index="/index/home">首页</el-menu-item>
        <el-menu-item index="/index/project">项目</el-menu-item>
        <el-menu-item index="/index/essay"> 论文 </el-menu-item>
        <el-menu-item index="/index/award"> 获奖 </el-menu-item>
        <el-menu-item index="/index/work">教材与著作</el-menu-item>
        <el-menu-item index="/index/patent">专利</el-menu-item>
      </el-menu>
      <!-- 设置 -->
      <div class="setting">
        <el-dropdown>
          <div class="imgbox">
            <el-button
              type="warning"
              icon="el-icon-error"
              circle
              @click="handleLogoLink"
            ></el-button>
          </div>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item><div @click="logout">退出</div></el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
    </el-header>

    <el-container>
      <el-main>
        <!-- 路由占位符 -->
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import { mapState, mapMutations, mapActions } from "vuex";
export default {
  name: "myIndex",
  data() {
    return {
      activePath: "",
      imgUrl: "",
    };
  },
  components: {},
  methods: {
    ...mapMutations(["delToken"]),
    ...mapActions(["getSubject_classificationList", "getCollegeList"]),
    handleSelect(key, keyPath) {
      // console.log(key, keyPath);
    },
    logout() {
      window.localStorage.clear();
      this.$router.push("/login");
      console.log(1);
    },
    handleLogoLink() {
      this.$router.push(
        {
          path: "/index",
        },
        () => {},
        () => {}
      );
    },
  },
  computed: {
    ...mapState(["moreUserInfo"]),
  },
  mounted() {
    this.activePath = this.$route.path;
    let _this = this;
    this.getSubject_classificationList({ _this });
    this.getCollegeList({ _this });
  },
};
</script>

<style lang="less" scoped>
.setting {
  width: 5%;
}
.el-dropdown {
  width: 20%;
  cursor: pointer;
  color: #ffffff;
  img {
    width: 100%;
    border-radius: 50%;
    /* 对图片的进行剪切，保留原始比例 */
    object-fit: cover;
    /* 图片在容器的正中间 */
    object-position: center;
  }
}
.el-menu-demo {
  width: 100%;
}
.home-container {
  height: 100%;
}
.el-header {
  background-color: #373d41;
  display: flex;
  justify-content: space-evenly;
  padding-left: 3%;
  align-items: center;
  color: #fff;
  font-size: 20px;
  > div {
    width: 20%;
    display: flex;
    align-items: center;

    img {
      margin-right: 2%;
    }

    span {
      margin-left: 1%;
    }
  }
}
.el-main {
  background-color: #eaedf1;
  padding: 0 !important;
}

span {
  cursor: pointer;
}

.out {
  margin-right: 2%;
}
</style>
